package vista;

import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import java.awt.event.ActionListener;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaIngrediente extends javax.swing.JFrame {
	private JPanel jPanelIngrediente;
	private JLabel jLblNombIngrediente;
	private JLabel jLblStock;
	private JTextField jNombIngrediente;
	private JButton jBtnRegistrarCompras;
	private JButton jBtnLimpiar;
	private JTextField jStock;
	private JButton jBtnEliminar;
	private JButton jBtnModificar;
	private JButton jBtnRegistrar;
	private JButton jBtnBuscar;
	private JTextField jDescrip;
	private JTextField jCodIngrediente;
	private JLabel jLblDescrip;
	private JLabel jLblCodIngrediente;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VistaIngrediente inst = new VistaIngrediente();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VistaIngrediente() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setBackground(new java.awt.Color(93,193,225));
			this.setTitle("SGECR [Modulo de Archivos] - Ingredientes");
			{
				jPanelIngrediente = new JPanel();
				GroupLayout jPanelIngredienteLayout = new GroupLayout((JComponent)jPanelIngrediente);
				jPanelIngrediente.setLayout(jPanelIngredienteLayout);
				jPanelIngrediente.setBackground(new java.awt.Color(173,216,230));
				{
					jLblCodIngrediente = new JLabel();
					jLblCodIngrediente.setText("Cod. Ingrediente:");
				}
				{
					jBtnModificar = new JButton();
					jBtnModificar.setText("Modificar");
				}
				{
					jBtnEliminar = new JButton();
					jBtnEliminar.setText("Eliminar");
				}
				{
					jBtnLimpiar = new JButton();
					jBtnLimpiar.setText("Limpiar");
				}
				{
					jLblStock = new JLabel();
					jLblStock.setText("Unidades en Stock: ");
				}
				{
					jBtnRegistrarCompras = new JButton();
					jBtnRegistrarCompras.setText("Registrar Compras");
					//controladorVentanaActualizar
				}
				{
					jCodIngrediente = new JTextField();
				}
				{
					jNombIngrediente = new JTextField();
				}
				{
					jDescrip = new JTextField();
				}
				{
					jStock = new JTextField();
				}
				{
					jBtnBuscar = new JButton();
					jBtnBuscar.setText("Buscar");
				}
				{
					jBtnRegistrar = new JButton();
					jBtnRegistrar.setText("Registrar");
				}
				{
					jLblNombIngrediente = new JLabel();
					jLblNombIngrediente.setText("Nombre:");
				}
				{
					jLblDescrip = new JLabel();
					jLblDescrip.setText("Descripción:");
				}
				jPanelIngredienteLayout.setVerticalGroup(jPanelIngredienteLayout.createSequentialGroup()
					.addContainerGap(27, 27)
					.addGroup(jPanelIngredienteLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelIngredienteLayout.createSequentialGroup()
					        .addComponent(jBtnBuscar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					        .addGap(7))
					    .addGroup(jPanelIngredienteLayout.createSequentialGroup()
					        .addGap(7)
					        .addGroup(jPanelIngredienteLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					            .addComponent(jCodIngrediente, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jLblCodIngrediente, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addGroup(jPanelIngredienteLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelIngredienteLayout.createSequentialGroup()
					        .addComponent(jBtnRegistrar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					        .addComponent(jBtnModificar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					        .addComponent(jBtnEliminar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					        .addComponent(jBtnLimpiar, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE))
					    .addGroup(jPanelIngredienteLayout.createSequentialGroup()
					        .addGap(14)
					        .addGroup(jPanelIngredienteLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					            .addComponent(jNombIngrediente, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jLblNombIngrediente, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					        .addGroup(jPanelIngredienteLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					            .addComponent(jDescrip, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jLblDescrip, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					        .addGroup(jPanelIngredienteLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					            .addComponent(jStock, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jLblStock, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
					        .addGap(27)))
					.addComponent(jBtnRegistrarCompras, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(29, Short.MAX_VALUE));
				jPanelIngredienteLayout.setHorizontalGroup(jPanelIngredienteLayout.createSequentialGroup()
					.addContainerGap(32, 32)
					.addGroup(jPanelIngredienteLayout.createParallelGroup()
					    .addGroup(jPanelIngredienteLayout.createSequentialGroup()
					        .addComponent(jBtnRegistrarCompras, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 0, Short.MAX_VALUE))
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelIngredienteLayout.createSequentialGroup()
					        .addComponent(jLblDescrip, GroupLayout.PREFERRED_SIZE, 101, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 36, Short.MAX_VALUE))
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelIngredienteLayout.createSequentialGroup()
					        .addComponent(jLblNombIngrediente, GroupLayout.PREFERRED_SIZE, 109, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 28, Short.MAX_VALUE))
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelIngredienteLayout.createSequentialGroup()
					        .addComponent(jLblCodIngrediente, GroupLayout.PREFERRED_SIZE, 125, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 12, Short.MAX_VALUE))
					    .addComponent(jLblStock, GroupLayout.Alignment.LEADING, 0, 137, Short.MAX_VALUE))
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(jPanelIngredienteLayout.createParallelGroup()
					    .addComponent(jCodIngrediente, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jNombIngrediente, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jDescrip, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jStock, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE))
					.addGap(46)
					.addGroup(jPanelIngredienteLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelIngredienteLayout.createSequentialGroup()
					        .addComponent(jBtnBuscar, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)
					        .addGap(17))
					    .addComponent(jBtnRegistrar, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jBtnModificar, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jBtnEliminar, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jBtnLimpiar, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(16, 16));
			}
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(27, 27)
				.addComponent(jPanelIngrediente, GroupLayout.PREFERRED_SIZE, 235, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(38, Short.MAX_VALUE));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(65, 65)
				.addComponent(jPanelIngrediente, GroupLayout.PREFERRED_SIZE, 405, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(73, Short.MAX_VALUE));
			pack();
			this.setSize(553, 330);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	
	public void addListener(ActionListener actionlistener)
	{
		jBtnBuscar.addActionListener(actionlistener);
		jBtnRegistrar.addActionListener(actionlistener);
		jBtnModificar.addActionListener(actionlistener);
		jBtnEliminar.addActionListener(actionlistener);
		jBtnLimpiar.addActionListener(actionlistener);
		//jBtnSalir.addActionListener(actionlistener);
		jBtnRegistrarCompras.addActionListener(actionlistener);
	}
	
	public void MostrarMensaje(String mensaje)
	{
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public String getCodIngrediente()
	{
	 return jCodIngrediente.getText();
	 
	}
	public String getNombIngrediente()
	{
	 return jNombIngrediente.getText();
	 
	}
	public String getDescrip()
	{
	 return jDescrip.getText();
	}
	public float getStock()
	{
	 return Float.valueOf(jStock.getText().trim()).floatValue();
	}
	public void setCodIngrediente(String cod)
	{
		jCodIngrediente.setText(cod);
	}
	public void setNombIngrediente(String nom)
	{
		jNombIngrediente.setText(nom);
	}
	public void setDescripcion(String des)
	{
		jDescrip.setText(des);
	}
	public void setStock(float sto)
	{
		jStock.setText(String.valueOf(sto));
	}
	public void Blanquear()
	{
		jCodIngrediente.setText("");
		jNombIngrediente.setText("");
		jDescrip.setText("");
		jStock.setText("");
	}
}
